package com.bolt.report.engine.fill;

import com.bolt.common.utils.StrUtil;
import com.bolt.report.engine.BindData;
import com.bolt.report.engine.FillElementVisitor;
import com.bolt.report.engine.export.Exporter;
import com.bolt.report.engine.model.Expression;

public class FillDataSetElement extends BaseFillElement<String> {


    private BindData bindData;


    public FillDataSetElement(FillContext fillContext, BindData bindData, Expression expr) {
        this.fillContext = fillContext;
        this.expr = expr;
        this.bindData = bindData;
    }

    @Override
    public String getValue() {
        if (StrUtil.isBlank(this.value)) {
            this.value = StrUtil.EMPTY;
        }
        return value;
    }

    public Expression getExpr() {
        return expr;
    }

    public FillContext getFillContext() {
        return fillContext;
    }

    public BindData getBindData() {
        return bindData;
    }

    public void setValue(String value) {
        if (StrUtil.isEmpty(value)) {
            this.value = StrUtil.EMPTY;
        } else {
            this.value = value;
        }
    }

    @Override
    public <T> void accept(FillElementVisitor<T> visitor, T arg) {
        visitor.visit(this, arg);
    }

    @Override
    public <E extends Exporter> void accept(ExporterVisitor<E> visitor, E exporter)  {
        visitor.visit(this,exporter);
    }

}